package main

import (
	"filestore-rebuild/config"
	"filestore-rebuild/handler"
	"github.com/gin-gonic/gin"
)

func main() {
	port := config.File.MustValue("server", "port", "8081")

	ginServer := gin.Default()

	// ginServer.POST("/file/mpupload/init", handler.InitialMultipartUploadHandler)
	// ginServer.POST("/file/mpupload/uppart", handler.UploadPartHandler)
	// ginServer.POST("/file/mpupload/complete", handler.CompleteUploadHandler)

	ginServer.POST("/login", handler.UserLoginHandler)
	ginServer.POST("/signup", handler.UserSignupHandler)
	userGroup := ginServer.Group("/user", handler.JWT())
	{
		userGroup.GET("/info", handler.UserInfoHandler)
		userGroup.POST("/update", handler.UpdateUserInfoHandler)
	}

	fileGroup := ginServer.Group("/file", handler.JWT())
	{
		fileGroup.POST("/upload", handler.FileUploadHandler)
		fileGroup.GET("/list", handler.FileListHandler)
		fileGroup.POST("/delete", handler.FileDeleteHandler)
		fileGroup.POST("/rename", handler.UserFileRenameHandler)
		fileGroup.POST("/fastupload", handler.FastUploadHandler)
		fileGroup.GET("/download", handler.DownloadFileHandler)
		// 分块上传
		fileGroup.POST("/file/mpupload/init", handler.InitialMultipartUploadHandler)
		fileGroup.POST("/file/mpupload/uppart", handler.UploadPartHandler)
		fileGroup.POST("/file/mpupload/complete", handler.CompleteUploadHandler)
	}

	ginServer.Run(":" + port)

}
